package com.jike.noobmoney.mvp.view.activity;

import android.view.View;
import android.widget.TextView;

import com.jike.noobmoney.R;
import com.jike.noobmoney.entity.AboutUsEntity;
import com.jike.noobmoney.net.RetrofitHelper;
import com.jike.noobmoney.util.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 商务合作
 */
public class CooperationActivity extends BaseActivity {


    @BindView(R.id.qq)
    TextView qq;
    @BindView(R.id.email)
    TextView email;
    private Call<AboutUsEntity> aboutUs;

    @Override
    protected int layoutResID() {
        return R.layout.activity_cooperation;
    }

    @Override
    protected void initData() {
        //getData();
        qq.setText("0632-5773338");
        email.setText("fycm99@163.com");
    }

    /**
     * 获取数据
     */
    private void getData() {
        aboutUs = RetrofitHelper.getInstance().getAboutUs();
        aboutUs.enqueue(new Callback<AboutUsEntity>() {
            @Override
            public void onResponse(Call<AboutUsEntity> call, Response<AboutUsEntity> response) {
                if (response != null) {
                    AboutUsEntity body = response.body();
                    if (body != null) {
                        if ("100".equals(body.getCode())) {
                            //获取qq email成功
                            initView(body);
                        } else {
                            ToastUtils.showShortToastSafe(body.getRinfo());
                        }
                    }
                }
            }

            @Override
            public void onFailure(Call<AboutUsEntity> call, Throwable t) {
                ToastUtils.showShortToastSafe(t.getMessage());
            }
        });

    }

    /**
     * 加载视图
     */
    private void initView(AboutUsEntity body) {
        qq.setText(body.getAbout().getMobile());
        email.setText(body.getAbout().getMail());

    }

    @OnClick({R.id.iv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }

}
